package modelos;

import java.sql.*;
import java.io.*;
import java.text.DateFormat;
import java.util.*;

public class Resumen{
    private int idResumen ;
    private int idArticulo;
    private String fechaDeCreacion;
    private String contenidoResumen;
    private Connection conn;
    private Statement stmt;

    
    public Resumen(){
        try {
            String userName = "root";
            String password = "";
            String url = "jdbc:mysql://localhost:3306/seng";;
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url, userName, password);
            stmt = conn.createStatement();
        } catch (Exception e) {
            System.out.println("Cannot connect to database server");
        }        
    }
    
    public void agregar() {
        try {
            String s = "INSERT INTO Resumen (id_articulo, contenido)"
                    + " VALUES ('"+idArticulo + "', '" + contenidoResumen + "')";
            System.out.println(s);
            stmt.executeUpdate(s);
            //int numero=stmt.executeUpdate(s, Statement.RETURN_GENERATED_KEYS);
        } catch (Exception e) {
            System.out.println("Cannot update database" + e);
        }
    }

    public void setIdResumen(int valor){
            idResumen = valor;
    }

    public int getIdResumen(){
            return idResumen;
    }

    public void setIdArticulo(int valor){
            idArticulo = valor;
    }

    public int getIdArticulo(){
            return idArticulo;
    }

    public void setFechaDeCreacion(String valor){
            fechaDeCreacion = valor;
    }

    public String getFechaDeCreacion(){
            return fechaDeCreacion;
    }
    
    public String getContenidoResumen() {
        return contenidoResumen;
    }

    public void setContenidoResumen(String contenidoResumen) {
        this.contenidoResumen = contenidoResumen;
    }
}